// components/segmentBar/segmentBar.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    segmentItems:{
      type: Array,
      value: []
    },
    isfbox:{
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    currentId: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    _changeIndex: function(newIndex){
      this.setData({
        currentId: newIndex
      })
    },
    _handlerTap: function(e){
      console.log("segmentBar.js _handlerTap\n",e)
      //抛出event，
      this.triggerEvent('selectItem', {currentId: e.currentTarget.id}, {})
      this._changeIndex(e.currentTarget.id)
    },
    _setSegmentItems: function(array){
      if(array[0] == ""){
        array=[]
      }
      this.setData({
        segmentItems: array,
        currentId: 0
      })
      this.triggerEvent('selectItem', {currentId: 0}, {})
    }
  }
})
